<template>
  <a-card :bordered="false">


    <!-- table区域-begin -->
    <div>


      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <span slot="status" slot-scope="text, record, index">
            <a-tag color="red" v-if="text==0">冻结</a-tag>
            <a-tag color="#87d068" v-if="text==1" >正常</a-tag>
          <a-tag color="bule" v-if="text==2" >部分赎回</a-tag>
          <a-tag color="#FFC107" v-if="text==3" >完全赎回</a-tag>
            <a-tag color="#4caf50" v-if="text==4" >赎回中</a-tag>
        </span>
        <span slot="action" slot-scope="text, record">

        </span>

      </a-table>
    </div>


  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import { deleteAction, getAction, putAction } from '@api/manage'

  export default {
    name: 'UserhomeFundListModal',
    mixins:[JeecgListMixin, mixinDevice],
    props: {
      userhomeId: {
        type: Number,
        default: ''
      },
    },
    components: {

    },
    data () {
      return {
        description: '用户基金管理页面',
        // 表头
        columns: [
          {
            title:'基金名',
            align:"center",
            dataIndex: 'fundname'
          },
          {
            title:'基金code',
            align:"center",
            dataIndex: 'fcode'
          },
          {
            title:'用户',
            align:"center",
            dataIndex: 'phone'
          },
          {
            title:'已购份额',
            align:"center",
            dataIndex: 'num'
          },
          {
            title:'基金状态',
            align:"center",
            dataIndex: 'status',
            scopedSlots: { customRender: 'status' }
          },
          {
            title:'订单号',
            align:"center",
            dataIndex: 'orderNum'
          },
          {
            title:'第三方订单号',
            align:"center",
            dataIndex: 'payNum'
          },
          {
            title:'已赎回份额',
            align:"center",
            dataIndex: 'redeemNum'
          },
          {
            title:'可赎回份额',
            align:"center",
            dataIndex: 'canRedeemNum'
          }
        ],
        url: {
          list: "/fund/userhomeFund/list",
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      loadData(arg) {
        if (!this.url.list) {
          this.$message.error("请设置url.list属性!")
          return
        }
        if (this.userhomeId == null || this.userhomeId == "") {
          return
        }
        this.queryParam.userhomeId = this.userhomeId;
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        var params = this.getQueryParams();//查询条件
        this.loading = true;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            this.dataSource = res.result.records || res.result;
            if (res.result.total) {
              this.ipagination.total = res.result.total;
            } else {
              this.ipagination.total = 0;
            }
            //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          } else {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.loading = false
        })
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'fundId',text:'基金id',dictCode:''})
        fieldList.push({type:'int',value:'num',text:'份额',dictCode:''})
        fieldList.push({type:'int',value:'status',text:'(0 冻结 1正常 2部回赎回 3完全赎回)',dictCode:'fund_status'})
        fieldList.push({type:'string',value:'orderNum',text:'订单号',dictCode:''})
        fieldList.push({type:'string',value:'payNum',text:'第三方订单号',dictCode:''})
        fieldList.push({type:'int',value:'userhomeId',text:'bigint',dictCode:''})
        fieldList.push({type:'int',value:'redeemNum',text:'已赎回份额',dictCode:''})
        fieldList.push({type:'int',value:'canRedeemNum',text:'可赎回份额',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>